package com.zhou.project.modules.circle.circlePostsCommentYes.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhou.project.components.base.service.BaseService;
import com.zhou.project.modules.circle.circlePostsCommentYes.dao.CommentYesDao;
import com.zhou.project.modules.circle.circlePostsCommentYes.entity.CommentYes;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CommentYesService extends BaseService<CommentYesDao, CommentYes> {

    //查询是否已经点过赞
    public boolean oneYes(int commentId){
        return baseMapper.oneYes(commentId,currentAuthentication.getCurrentUserId())==0?true:false;
    }
    //如果点过调用取消点赞
    @Transactional
    public void noYes(int commentId){
        baseMapper.deleteThis(commentId,currentAuthentication.getCurrentUserId());
    }

    //查询某个话题点赞的数量
    public long countCommentYes(int commentId)
    {
        return baseMapper.countCommentYes(commentId);
    }

}

